package apis

import (
	"k8sdev/pkg/services"
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
)

func WatchPods(c *gin.Context) {
	namespaceName := c.Param("namespaceName")
	w, err := services.WatchPods(namespaceName)
	if err != nil {
		log.Fatal(err.Error())
		return
	}
	for e := range w.ResultChan() {
		c.JSON(http.StatusOK, gin.H{
			"Type":   e.Type,
			"Object": e.Object,
		})
	}
}
